package com.woniuxy.controller;

import com.woniuxy.entity.UserManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @Author 罗蔚
 * @Date 2022/3/30 16:39
 * @Description TODO
 */
@Controller
public class LoginController {
    @RequestMapping("/login")
    public ModelAndView login(String username, @RequestParam("pass") String password) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg", username + "..." + password);
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }

    @RequestMapping("/passArray")
    public ModelAndView passArray(String username, String[] hobby) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg", username + "..." + Arrays.toString(hobby));
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }

    @RequestMapping("/passList")
    public ModelAndView passList(String username, @RequestParam List<String> hobby) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg", username + "..." + hobby.toString());
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }

    @RequestMapping("/passMap")
    public ModelAndView passMap(@RequestParam Map<String, Object> map, @RequestParam List<String> hobby) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg", map + "..." + hobby.toString());
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }
    @RequestMapping("/passObject")
    public ModelAndView passObject(UserManager userManager){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg", userManager);
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }
    @RequestMapping("/passDate")
    public ModelAndView passDate(UserManager userManager){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg", userManager);
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }
}
